
package com.hexinfo.dmpro.sparing.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hexinfo.dmpro.common.utils.CommonConstants;
import com.hexinfo.dmpro.sparing.model.SyncAuditBlackList;
import com.hexinfo.dmpro.sparing.model.SyncCompleteLibraryTask;
import com.hexinfo.dmpro.sparing.model.SyncFullAuditTask;
import com.hexinfo.dmpro.sparing.dao.SyncFullAuditTaskMapper;
import com.hexinfo.dmpro.sparing.service.SyncFullAuditTaskService;
import org.springframework.stereotype.Service;

/**
 * 全量稽核日志任务表
 *
 * @author yemw
 * @date 2024-01-23 10:40:41
 */
@Service
public class SyncFullAuditTaskServiceImpl extends ServiceImpl<SyncFullAuditTaskMapper, SyncFullAuditTask> implements SyncFullAuditTaskService {

    @Override
    public Page queryList(Page page, SyncFullAuditTask syncFullAuditTask) {
        LambdaQueryWrapper<SyncFullAuditTask> wrapper = Wrappers.lambdaQuery();
        wrapper.like(StrUtil.isNotBlank(syncFullAuditTask.getTaskName()),SyncFullAuditTask::getTaskName,syncFullAuditTask.getTaskName())
                .like(StrUtil.isNotBlank(syncFullAuditTask.getTableNameList()),SyncFullAuditTask::getTableNameList,syncFullAuditTask.getTableNameList())
                .eq(StrUtil.isNotBlank(syncFullAuditTask.getTaskState()), SyncFullAuditTask::getTaskState,syncFullAuditTask.getTaskState())
                .apply(StrUtil.isNotBlank(syncFullAuditTask.getStaDate()),"CREATE_TIME between to_date('" + syncFullAuditTask.getStaDate() + "','yyyy-MM-dd HH24:MI:SS') and to_date('"+ syncFullAuditTask.getEndDate() + "','yyyy-MM-dd HH24:MI:SS')")
                .eq(SyncFullAuditTask::getDel,CommonConstants.STATUS_NORMAL).orderByDesc(SyncFullAuditTask::getCreateTime);
        Page returnPage = this.baseMapper.selectPage(page, wrapper);
        return returnPage;
    }
}
